package com.netease.framework.db;

import java.util.LinkedList;
import java.util.List;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;

import com.netease.framework.db.DBSupport.CollectorTable;

/**
 * 封装统计信息读写接口
 * @author Panjf
 * @date   2011-10-9
 */
public class Collector {
	
	public static List<String> getCollector(Context context){
		Cursor c = context.getContentResolver().query(CollectorTable.Collector_URI, 
		                                   null, null, null, null);
		
		List<String> collectors = new LinkedList<String>();

		if(c != null && c.moveToPrevious()){
			while(c.moveToNext()){
				String str = c.getString(c.getColumnIndex(CollectorTable.COLLECTOR));
				collectors.add(str);
			}
		}
		
		if(c != null)
			c.close();
		
		return collectors;
	}
	
	public static void insertCollector(Context context,   String collStr){
		
		ContentValues initialValues = new ContentValues();
		initialValues.put(CollectorTable.COLLECTOR, collStr);
	    context.getContentResolver().insert(CollectorTable.Collector_URI, initialValues);
	}
	
	public static int deleteAllCollector(Context context){
		return context.getContentResolver().delete(CollectorTable.Collector_URI,null, null);
	}
}
